package thread.java20221220;

/**
 * 线程不安全演示
 */
public class Demo24 {
    private static int count = 0;

    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 5_0000; i++) {
                count++;
            }
        });

        t1.start();
        //打印count值的时候, 需要等待t1 和t2 执行完
        t1.join();

        //main线程的执行
        for (int i = 0; i < 5_0000; i++) {
            count++;
        }



        System.out.println(count);

    }
}
